package com.itcast.reflect;

import com.itcast.domain.Person;
import com.itcast.domain.Student;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {

        // 1
        // 多用于配置文件，将类名定义在配置文件中。读取文件，加载类
        Class<?> c1 = Class.forName("com.itcast.domain.Person");
        System.out.println(c1);

        // 2
        // 多用于参数传递
        Class<Person> c2 = Person.class;
        System.out.println(c2);

        // 3
        Person p = new Person();
        Class<? extends Person> c3 = p.getClass();
        System.out.println(c3);

        // 用 == 比较三个对象
        System.out.println(c1 == c2);
        System.out.println(c1 == c3);

        Class<Student> s = Student.class;
        System.out.println(s == c1);

    }
}
